import request from '@/utils/request';
export function department() {
  return request ({
    url: '/company/department',
    method: 'get'
  })
   .then(res => {
    // console.log(res.data.data.depts)
    return res.data.data.depts
   })
   .catch(err => err)
}
// 公司数据
export function company(id) {
  return request ({
    url: '/company/' + id,
    method: 'get'
  })
   .then(res => {
    // console.log(res.data.data)
    return res.data.data
   })
   .catch(err => err)
}
// 获取部门负责人数据
export function getManager() {
  return request ({
    url: '/sys/user/simple',
    method: 'get'
  })
   .then(res => {
    // console.log(res.data)
    return res.data.data
   })
   .catch(err => err)
}
// 新增部门
export function addDepartment(data) {

  return request ({
    url: '/company/department',
    method: 'post',
    data: {
      ...data
    }
  })
   .then(res => {
    // console.log(res.data)
    return res.data.message
   })
   .catch(err => Promise.reject(err.response.data.message))
}
// 删除部门
export function deleteDepartment(id) {

  return request ({
    url: '/company/department/' + id,
    method: 'delete',
  })
   .then(res => {
    // console.log(res.data)
    return res.data.message
   })
   .catch(err => Promise.reject(err.response.data.message))
}
// 获取单个部门详情
export function getDepartmentDetail(id) {
  return request ({
    url: '/company/department/' + id,
    method: 'get',
  })
   .then(res => {
    // console.log(res.data)
    return res.data.data
   })
   .catch(err => err)
}
// 修改单个部门详情
export function editDepartment(data) {
  return request ({
    url: '/company/department/' + data.id,
    method: 'put',
    data: {
      ...data
    }
  })
   .then(res => {
    return res.data.message
   })
   .catch(err => Promise.reject(err.response.data.message))
}
